﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Senac.ProjetoIntegrador.Model;
using Senac.ProjetoIntegrador.Service;
 
namespace Senac.ProjetoIntegrador.Controllers
{
    public class UsuarioController : Controller
    {
     
        public ActionResult Index()
        {
            return View("Login");
        }

     
        public ActionResult Details(int id)
        {
            return View();
        }

        public ActionResult Login()
        {
            return View();
        } 

        [HttpPost]
        public ActionResult Login(Usuario Usuario)
        {
            try
            {
                Usuario _Usuario = new UsuarioService().BuscarLogin(Usuario.desc_login_email, Usuario.desc_senha);
                string tela = " ";
                if (_Usuario.Autenticacao)
                {
                    switch (_Usuario.desc_tipo)
                    {
                        case "ADM":
                            tela = "atividade"; // alterar 
                            break;

                        case "PRO":
                            tela = "atividade"; // alterar
                            break;

                        case "ALU":
                            tela = "atividade"; //alterar 
                            break;   

                    }
                    return RedirectToAction("Index", tela);
                }
                else 
                {
                    return RedirectToAction("CreatePergunta", "Atividade");
                }
            }
            catch
            {
                return View();
            }
        }
        
        public ActionResult Edit(int id)
        {
            return View();
        }

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        public ActionResult Delete(int id)
        {
            return View();
        }

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
